package com.liuym.common.constants;

public class GradeResponse<DATA> {

    private int code;
    private String msg;
    private DATA data;

    public GradeResponse() {
    }

    public GradeResponse(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public GradeResponse(int code, String msg, DATA data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public DATA getData() {
        return data;
    }

    public void setData(DATA data) {
        this.data = data;
    }

    public static GradeResponse success() {
        return new GradeResponse(ResponseCodeConstants.SUCCESS_CODE, ResponseCodeConstants.SUCCESS_MSG);
    }

    public static <DATA> GradeResponse<DATA> success(DATA data) {
        return new GradeResponse<DATA>(ResponseCodeConstants.SUCCESS_CODE, ResponseCodeConstants.SUCCESS_MSG, data);
    }

    public static GradeResponse internalServerError() {
        return new GradeResponse(ResponseCodeConstants.INTERNAL_SERVER_ERROR_CODE, ResponseCodeConstants.INTERNAL_SERVER_ERROR_MSG);
    }

    public static <DATA> GradeResponse<DATA> fail(int code, String msg, DATA data) {
        return new GradeResponse(code, msg, data);
    }

    public static <DATA> GradeResponse<DATA> fail(int code, String msg) {
        return new GradeResponse(code, msg);
    }

    public static <DATA> GradeResponse<DATA> success(String msg, DATA data) {
        return new GradeResponse(ResponseCodeConstants.SUCCESS_CODE, msg, data);
    }
}
